package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.CmdbMemoryStandardDto;
import com.glsc.ngateway.common.base.domain.mysql.cmdb.CmdbMemoryStandard;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class CmdbMemoryStandardConverter {

    public static CmdbMemoryStandardDto do2Dto(CmdbMemoryStandard domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        return CmdbMemoryStandardMapper.INSTANCE.do2Dto(domain);
    }

    public static List<CmdbMemoryStandardDto> do2Dto(List<CmdbMemoryStandard> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(CmdbMemoryStandardConverter::do2Dto).collect(Collectors.toList());
    }

    public static CmdbMemoryStandard dto2Do(CmdbMemoryStandardDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return CmdbMemoryStandardMapper.INSTANCE.dto2Do(dto);
    }

    public static List<CmdbMemoryStandard> dto2Do(List<CmdbMemoryStandardDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(CmdbMemoryStandardConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface CmdbMemoryStandardMapper {

        CmdbMemoryStandardMapper INSTANCE = Mappers.getMapper(CmdbMemoryStandardMapper.class);

        CmdbMemoryStandardDto do2Dto(CmdbMemoryStandard domain);

        List<CmdbMemoryStandardDto> do2Dto(List<CmdbMemoryStandard> domain);

        CmdbMemoryStandard dto2Do(CmdbMemoryStandardDto dto);

        List<CmdbMemoryStandard> dto2Do(List<CmdbMemoryStandardDto> dto);
    }
}
